package com.wzy.netty.core.http;

import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.codec.http.HttpServerCodec;

/**
 * 描述
 * 创建人    Wzy
 * 创建时间: 2020-05-21  20:43
 */
public class TestServerInitializer extends ChannelInitializer<SocketChannel> {
    @Override
    protected void initChannel(SocketChannel ch) throws Exception {
        //向管道加入处理器

        //得到管道
        ChannelPipeline pipeline = ch.pipeline();
        //加入netty提供的httpServerCode codec=> coder- decoder
        pipeline.addLast("myHttpServerCodec", new HttpServerCodec());
        //增加一个自定义的handler
        pipeline.addLast("myTestHttpServerHandler", new TestHttpServerHandler());
        System.out.println("ok");
    }
}
